﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AnimItem : MonoBehaviour, INormalItem
{
    public UGUIToggle toggle;
    public Text animNameTex;

    private string animName = string.Empty;
    private bool select = false;
    public void SetData(string animName)
    {
        this.animName = animName;
        animNameTex.text = animName;
        toggle.onValueChangedEvent = ToggleSelect;
    }

    public void ToggleSelect(object obj,bool value)
    {
        select = value;
        if (value == true)
        {
            EventManager.TriggerEvent<string>(CommonEvent.SelectOneAnimSlot, animName);
        }
    }
    public void DelateAnim()
    {
        EventManager.TriggerEvent<string>(CommonEvent.DelateOneAnimSlot, animName);
    }

    public void OnRecycle()
    {
        toggle.isOn = false;
        toggle.onValueChangedEvent = null;
    }
}
